package com.cy.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @Author ChenYan
 * @Date 2021/7/1 14:39
 * @Description
 */
public class Handler {

    /**
     * 是哪个类
     */
    private Object controller;

    /**
     * 具体执行的方法
     */
    private Method method;

    /**
     * 匹配的正则表达式
     */
    private Pattern pattern;

    /**
     * 参数顺序，为了在反射调用时进行参数绑定，key是参数名，value是顺序
     */
    private Map<String, Integer> paramIndexMapping;

    public Handler(Object controller, Method method, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
    }

    /**
     * Gets the value of controller. *
     *
     * @return the value of controller
     */
    public Object getController() {
        return controller;
    }

    /**
     * Sets the controller. *
     * <p>You can use getController() to get the value of controller</p>
     * * @param controller controller
     */
    public void setController(Object controller) {
        this.controller = controller;
    }

    /**
     * Gets the value of method. *
     *
     * @return the value of method
     */
    public Method getMethod() {
        return method;
    }

    /**
     * Sets the method. *
     * <p>You can use getMethod() to get the value of method</p>
     * * @param method method
     */
    public void setMethod(Method method) {
        this.method = method;
    }

    /**
     * Gets the value of pattern. *
     *
     * @return the value of pattern
     */
    public Pattern getPattern() {
        return pattern;
    }

    /**
     * Sets the pattern. *
     * <p>You can use getPattern() to get the value of pattern</p>
     * * @param pattern pattern
     */
    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    /**
     * Gets the value of paramIndexMapping. *
     *
     * @return the value of paramIndexMapping
     */
    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    /**
     * Sets the paramIndexMapping. *
     * <p>You can use getParamIndexMapping() to get the value of paramIndexMapping</p>
     * * @param paramIndexMapping paramIndexMapping
     */
    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
